<template>
	<view class="detail-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="true" color="#fff" title="内容详情"></uni-navbar></view>

		<view class="detail-info" v-show="detailInfo.infoObj.id">
			<view class="info-title">
				<view class="title-top">{{ detailInfo.infoObj.title }}</view>
				<view class="title-btm">
					<text class="btm-time">{{ detailInfo.infoObj.createTime | parseTime('{y}-{m}-{d}') }}</text>
				</view>
			</view>
			<view class="info-detail">
				<view class="info-h2">提交人</view>
				<view>{{ detailInfo.infoObj.submitName }}</view>
				<view class="info-line"></view>
				<view class="info-h2">基本情况</view>
				<view class="overflow" v-html="detailInfo.infoObj.subBackground"></view>
			</view>
		</view>

		<view class="uploader-add" @click="onTts">
			<image v-if="!play" src="/static/img/icon_76.png" mode="widthFix"></image>
			<image src="/static/img/icon_77.gif" v-else mode="widthFix"></image>
		</view>

		<view class="form-box form-box-show">
			<u-tabs class="uTabs" :list="tabs" :current="current" @change="tabsChange"></u-tabs>
			<u-form ref="uForm" v-if="current == 0 && detailInfo.filterObj">
				<u-form-item class="form-item" label="初审人" labelAlign="left" label-width="190">{{ detailInfo.filterObj.reportName }}</u-form-item>
				<u-form-item class="form-item" label="初审时间" labelAlign="left" label-width="190">
					<block v-if="detailInfo.filterObj.reportTime">{{ detailInfo.filterObj.reportTime | parseTime('{y}-{m}-{d}') }}</block>
				</u-form-item>
				<u-form-item class="form-item" label="说明理由" labelAlign="left" label-width="190">{{ detailInfo.filterObj.scReasons }}</u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 1 && detailInfo.filterObj">
				<u-form-item class="form-item" label="审定人员" labelAlign="left" label-width="190">{{ detailInfo.filterObj.valValName }}</u-form-item>
				<u-form-item class="form-item" label="审定时间" labelAlign="left" label-width="190">
					<block v-if="detailInfo.filterObj.valValTime">{{ detailInfo.filterObj.valValTime | parseTime('{y}-{m}-{d}') }}</block>
				</u-form-item>
				<u-form-item class="form-item" label="审定意见" labelAlign="left" label-width="190">
					<block v-if="detailInfo.filterObj.valNion">{{ detailInfo.filterObj.valNion == '1' ? '通过' : '不通过' }}</block>
				</u-form-item>
				<u-form-item class="form-item" label="审定理由" labelAlign="left" label-width="190">{{ detailInfo.filterObj.valTion }}</u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 2 && detailInfo.infoObj">
				<u-form-item class="form-item" label="公示期限" labelAlign="left" label-width="190">{{ detailInfo.infoObj.issPeriod }}</u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 3 && detailInfo.surveyObj">
				<u-form-item class="form-item" label="调研时间" labelAlign="left" label-width="190">
					<block v-if="detailInfo.surveyObj.startTime">{{ detailInfo.surveyObj.startTime + ' - ' + detailInfo.surveyObj.endTime }}</block>
				</u-form-item>
				<u-form-item class="form-item" label="调研地点" labelAlign="left" label-width="190">{{ detailInfo.surveyObj.surPlace }}</u-form-item>
				<u-form-item class="form-item" label="人大代表" labelAlign="left" label-width="190">
					<block v-if="detailInfo.surveyObj.surSeMember">
						<block v-for="(item, index) in JSON.parse(detailInfo.surveyObj.surSeMember)" :key="item.id">
							{{ item.memberName }}{{ index == JSON.parse(detailInfo.surveyObj.surSeMember).length - 1 ? '' : ',' }}
						</block>
					</block>
				</u-form-item>
				<u-form-item class="form-item" label="其他人员" labelAlign="left" label-width="190">
					<block v-if="detailInfo.surveyObj.surInMember">
						<block v-for="(item, index) in JSON.parse(detailInfo.surveyObj.surInMember)" :key="item.id">
							{{ item.memberName }}{{ index == JSON.parse(detailInfo.surveyObj.surInMember).length - 1 ? '' : ',' }}
						</block>
					</block>
				</u-form-item>
				<u-form-item class="form-item" label="调研内容" labelAlign="left" label-width="190"><view v-html="detailInfo.surveyObj.surInfo"></view></u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 4 && detailInfo.consultObj">
				<u-form-item class="form-item" label="协商地点" labelAlign="left" label-width="190">{{ detailInfo.consultObj.conPlace }}</u-form-item>
				<u-form-item class="form-item" label="协商时间" labelAlign="left" label-width="190">
					<block v-if="detailInfo.consultObj.conTime">{{ detailInfo.consultObj.conTime | parseTime('{y}-{m}-{d}') }}</block>
				</u-form-item>
				<u-form-item class="form-item" label="人大代表" labelAlign="left" label-width="190">
					<block v-if="detailInfo.consultObj.conPerson">
						<block v-for="(item, index) in JSON.parse(detailInfo.consultObj.conPerson)" :key="item.id">
							{{ item.name }}{{ index == JSON.parse(detailInfo.consultObj.conPerson).length - 1 ? '' : ',' }}
						</block>
					</block>
				</u-form-item>
				<u-form-item class="form-item" label="其他人员" labelAlign="left" label-width="190">
					<block v-if="detailInfo.consultObj.othPerson">
						<block v-for="(item, index) in JSON.parse(detailInfo.consultObj.othPerson)" :key="item.id">
							{{ item.memberName }}{{ index == JSON.parse(detailInfo.consultObj.othPerson).length - 1 ? '' : ',' }}
						</block>
					</block>
				</u-form-item>
				<u-form-item class="form-item" label="协商内容" labelAlign="left" label-width="190"><view v-html="detailInfo.consultObj.conContent"></view></u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 5 && detailInfo.consultObj">
				<u-form-item class="form-item" label="协商建议" labelAlign="left" label-width="190"><view v-html="detailInfo.consultObj.conSuggest"></view></u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 6 && detailInfo.impleObj">
				<u-form-item class="form-item" label="联系代表" labelAlign="left" label-width="190">{{ detailInfo.impleObj.committeeName }}</u-form-item>
				<u-form-item class="form-item" label="完成时间" labelAlign="left" label-width="190">
					<block v-if="detailInfo.impleObj.endTime">{{ detailInfo.impleObj.endTime | parseTime('{y}-{m}-{d}') }}</block>
				</u-form-item>
			</u-form>
			<u-form ref="uForm" v-if="current == 7 && detailInfo.infoObj">
				<u-form-item class="form-item" label="公示期限" labelAlign="left" label-width="190">{{ detailInfo.infoObj.resPeriod }}</u-form-item>
			</u-form>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			typeList: {},
			current: 0,
			tabs: [
				{
					name: '初审信息'
				},
				{
					name: '审定信息'
				},
				{
					name: '公示信息'
				},
				{
					name: '商前调研'
				},
				{
					name: '协商情况'
				},
				{
					name: '协商结果'
				},
				{
					name: '成果审核'
				},
				{
					name: '结果公示'
				}
			],
			id: '',
			detailInfo: '',
			play: false
		};
	},
	onLoad(option) {
		this.loadLogin();
		this.id = option.id;
		this.loadData();
	},
	onHide() {
		this.$ttsOff();
	},
	onUnload() {
		this.$ttsOff();
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.sysUser) {
				this.clientCode = this.userInfo.sysUser.clientCode;
			} else {
				this.$logout();
			}
		},
		loadDict(type, list) {
			this.$request('/system/sys-dict/dictList', {
				clientCode: this.clientCode,
				sysDict: {
					dictType: type
				}
			}).then(res => {
				if (!res.data) {
					return false;
				}
				res.data.forEach(item => {
					this[list][item.dictValue] = item.dictName;
				});
			});
		},
		loadData() {
			this.$request(
				'/xieshangyishi/info/getAllProInfo',
				{
					clientCode: this.clientCode,
					id: this.id
				},
				{
					method: 'GET'
				}
			).then(res => {
				this.detailInfo = res.data;
			});
		},
		tabsChange(index) {
			this.current = index;
		},
		onTts() {
			let text = this.detailInfo.infoObj.title;
			text += ',' + this.detailInfo.infoObj.submitName;
			text += ',' + this.$parseTime(this.detailInfo.infoObj.createTime, '{y}-{m}-{d}');
			text += ',' + this.$htmlRegx(this.detailInfo.infoObj.subBackground);
			this.$tts(text, this, 500);
		},
		previewImage(idx, images) {
			uni.previewImage({
				current: idx,
				urls: images
			});
		}
	}
};
</script>

<style lang="scss">
.detail-view {
	background-color: #fff;
}

.form-box {
	border-top: 10rpx solid #f5f7fa;

	.form-item {
		display: block;
		padding: 0 30rpx;
	}
}

.fiexd-btm {
	position: static;
	border-top: 10rpx solid #f5f7fa;
	padding: 30rpx;
}
</style>
